country = 'colo'

v= 'any'
source(paste("config_code/",country,"_data_setup.R",sep = ""))
source(paste("config_code/",country,"_dependent_vars.R",sep = ""))
source(paste("config_code/",country,"_predictor_vars.R",sep = ""))

ds.labels <- attributes(dta)$var.labels

ds_cerac <- c("rhs_guerattL0", 
              "rhs_parattL0", 
              "rhs_govattL0", 
              "rhs_parmassL0", 
              "rhs_guermassL0", 
              "rhs_parattinfL0", 
              "rhs_parattniL0", 
              "rhs_attacksL0", 
              "rhs_clashesL0", 
              "rhs_casualtiesL0", 
              "rhs_violenceL0", 
              "rhs_violenceDUML0", 
              "rhs_violenceHIGHDUML0", 
              "rhs_violspikeL0"
)

ds_cede <- c( "rhs_lnnewpop", 
              "rhs_largemetro", 
              "rhs_popdensity",
              "rhs_lnnewpopGrL0",
              "rhs_metro", 
              "rhs_dnprevtot", 
              "rhs_dnpspendtot", 
              "rhs_dnprevcurrent", 
              "rhs_dnpspendcurrent", 
              "rhs_dnpdeficitcurr", 
              "rhs_dnpspendcap", 
              "rhs_dnprevtax", 
              "rhs_dnprevnontax", 
              "rhs_dnpspendfun", 
              "rhs_dnpspendcapoth", 
              "rhs_dnprevtaxland", 
              "rhs_dnprevtaxind", 
              "rhs_dnprevtaxoth", 
              "rhs_dnpspendperson", 
              "rhs_dnprevcapL0", 
              "rhs_dnpdeficittotL0", 
              "rhs_dnpfinancingL0", 
              "rhs_dnprevcurtranL0", 
              "rhs_dnpspendcapformL0", 
              "rhs_dnpcreditL0", 
              "rhs_dnpbalL0", 
              "rhs_dnpspendgenL0", 
              "rhs_dnpspendtranL0", 
              "rhs_nationexp", 
              "rhs_averageslope", 
              "rhs_stdslope", 
              "rhs_slightlyflatp", 
              "rhs_slightlyslopedp", 
              "rhs_moderatelyslopedp", 
              "rhs_stronglyslopedp", 
              "rhs_slightlysteepp", 
              "rhs_moderatelysteepp", 
              "rhs_stronglysteepp", 
              "rhs_averagewater", 
              "rhs_stdwater", 
              "rhs_mriv", 
              "rhs_sriv", 
              "rhs_triv", 
              "rhs_dmriv2", 
              "rhs_dsriv2", 
              "rhs_dtriv2", 
              "rhs_splain", 
              "rhs_shill", 
              "rhs_smount", 
              "rhs_svall", 
              "rhs_swat", 
              "rhs_shill2", 
              "rhs_smount2", 
              "rhs_srug", 
              "rhs_maxslop", 
              "rhs_p_main_roads", 
              "rhs_np_main_roads", 
              "rhs_p_sec_roads", 
              "rhs_np_sec_roads", 
              "rhs_dirt_roads", 
              "rhs_den_p_main_roads", 
              "rhs_den_np_main_roads", 
              "rhs_den_p_sec_roads", 
              "rhs_den_np_sec_roads", 
              "rhs_den_dirt_roads", 
              "rhs_inhabitable", 
              "rhs_areakm",
              "rhs_elec_al_turnout", 
              "rhs_elec_ca_turnout", 
              "rhs_elec_se_turnout", 
              "rhs_elec_d_nat", 
              "rhs_elec_d_president", 
              "rhs_elec_d_loc", 
              "rhs_elec_d_mayor", 
              "rhs_elec_hhi_ca", 
              "rhs_elec_F_ca", 
              "rhs_elec_P_ca", 
              "rhs_elec_hhi_se", 
              "rhs_elec_F_se", 
              "rhs_elec_P_se", 
              "rhs_elec_margin_1_ca", 
              "rhs_elec_margin_1_se", 
              "rhs_elec_s_1st_al", 
              "rhs_elec_s_1st_ca", 
              "rhs_elec_s_2nd_ca", 
              "rhs_elec_s_1st_se", 
              "rhs_elec_s_2nd_se", 
              "rhs_elec_leaning_1_ca_Rest", 
              "rhs_elec_leaning_1_ca_CRight", 
              "rhs_elec_leaning_1_ca_CLeft", 
              "rhs_elec_leaning_1_se_Rest", 
              "rhs_elec_leaning_1_se_CRight", 
              "rhs_elec_leaning_1_se_CLeft", 
              "rhs_elec_leaning_2_ca_Rest", 
              "rhs_elec_leaning_2_ca_CRight", 
              "rhs_elec_leaning_2_ca_CLeft", 
              "rhs_elec_leaning_2_se_Rest", 
              "rhs_elec_leaning_2_se_CRight", 
              "rhs_elec_leaning_2_se_CLeft", 
              "rhs_elec_party_1st_al_Other", 
              "rhs_elec_party_1st_al_Liberal", 
              "rhs_elec_party_1st_al_Conserv", 
              "rhs_elec_party_1st_ca_Other", 
              "rhs_elec_party_1st_ca_Liberal", 
              "rhs_elec_party_1st_ca_Conserv", 
              "rhs_elec_party_1st_se_Other", 
              "rhs_elec_party_1st_se_Liberal", 
              "rhs_elec_party_1st_se_Conserv", 
              "rhs_elec_party_2nd_ca_Other", 
              "rhs_elec_party_2nd_ca_Liberal", 
              "rhs_elec_party_2nd_ca_Conserv", 
              "rhs_elec_party_2nd_se_Other", 
              "rhs_elec_party_2nd_se_Liberal", 
              "rhs_elec_party_2nd_se_Conserv"
)

ds_nfcg <- c( "rhs_cofintxlinternalpL0", 
              "rhs_linternalpL0", 
              "rhs_cofint"
)

ds_ifsmme <- c("rhs_oilprod88xlopL0")

ds_imfusgs <- c("rhs_coalres78xlcoalpL0")

ds_ifs <- c("rhs_lopL0")

ds_gfd <- c("rhs_lgoldpL0",
            "rhs_lsilverpL0",
            "rhs_lplatpL0")
ds_imf <- c("rhs_lcoalpL0")

ds_gfdjacome <- c("rhs_mining78xlgoldpL0",
                  "rhs_mining78xlsilverpL0",
                  "rhs_mining78xlplatpL0")

ds_mme <- c("rhs_oilprod88")

ds_jacome <- c("rhs_mining78")

ds_usgs <- c("rhs_coalres78")

ds_igneominas <- c("rhs_coal_deptL0",
                   "rhs_gold_dept87",
                   "rhs_coal_dept90",
                   "rhs_gold_deptL0")

ds_agministry <- c("rhs_optimal_sugar", 
                   "rhs_suboptimal_sugar", 
                   "rhs_suitable_sugar", 
                   "rhs_nosuitable_sugar", 
                   "rhs_optimal_palm", 
                   "rhs_suboptimal_palm", 
                   "rhs_suitable_palm", 
                   "rhs_nosuitable_palm"
)

ds_dane <- c("rhs_gini_land",
             "rhs_ubn93",
             "rhs_lqi93")

ds_dne <- c("rhs_hpoppy1994", 
            "rhs_dpoppy1994", 
            "rhs_hcoca1994", 
            "rhs_dcoca1994", 
            "rhs_errad1994", 
            "rhs_derrad1994"
)

ds_unodc <- c("rhs_cocahec_bolL0", 
              "rhs_cocahec_colL0", 
              "rhs_cocahec_peruL0", 
              "rhs_cocahec_totL0", 
              "rhs_coke_bolL0", 
              "rhs_coke_peruL0", 
              "rhs_coke_colL0", 
              "rhs_coke_totL0", 
              "rhs_coke_notcolL0", 
              "rhs_coca_eradbolL0", 
              "rhs_coca_leafbolL0", 
              "rhs_cocaine_prodbolL0", 
              "rhs_coca_eradcolL0", 
              "rhs_coca_leafcolL0", 
              "rhs_cocaine_prodcol", 
              "rhs_coca_eradperuL0", 
              "rhs_coca_leafperuL0", 
              "rhs_cocaine_prodperuL0", 
              "rhs_lcpreL0", 
              "rhs_lcpwuL0", 
              "rhs_lcpweL0"
)

ds_dneunodc <- c("rhs_cocaxwcocapusL0")

ds_udel <- c( "rhs_rain_deviationL0", 
              "rhs_temp_deviationL0", 
              "rhs_rain_average", 
              "rhs_rain_sd", 
              "rhs_temp_average", 
              "rhs_temp_sd"
)

ds_acemoglu <- c( "rhs_CrownEmployees", 
                  "rhs_NonMilEmployees", 
                  "rhs_ColStatePresence", 
                  "rhs_CityStatus", 
                  "rhs_RoyalRoad", 
                  "rhs_SlaveShare1843", 
                  "rhs_SlavesDum1843", 
                  "rhs_Indians", 
                  "rhs_Encomiendas", 
                  "rhs_EncomiendasDum", 
                  "rhs_GoldMineDum", 
                  "rhs_FoundDate", 
                  "rhs_Pop1843", 
                  "rhs_MissPop1843"
)

ds_authors <- c("rhs_dmz_dum",
                "rhs_dmz_distance")

ds_usaid <- c("rhs_usmil_lrmil_colL0", 
              "rhs_usmil_lrnar_colL0", 
              "rhs_usmil_lrmilnar_colL0"
)

ds_dubenaidu <- c("rhs_usmil_bases6")

ds_dubeusaid <- c("rhs_usmil_bases6xlrmilnar_colL0", 
                  "rhs_usmil_bases6xlrmil_colL0", 
                  "rhs_usmil_bases6xlrnar_colL0"
)

dataset_key <- c()

for (x in ds_cerac) {
  dataset_key[x] <-'CERAC'
}

for (x in ds_cede) {
  dataset_key[x] <-'CEDE'
}

for (x in ds_nfcg) {
  dataset_key[x] <-'NFCG'
}

for (x in ds_ifsmme) {
  dataset_key[x] <-'IFS/MME'
}

for (x in ds_ifsmme) {
  dataset_key[x] <-'IFS/MME'
}

for (x in ds_imfusgs) {
  dataset_key[x] <-'IMF/USGS'
}

for (x in ds_ifs) {
  dataset_key[x] <-'IFS'
}

for (x in ds_gfd) {
  dataset_key[x] <-'GFD'
}

for (x in ds_imf) {
  dataset_key[x] <-'IMF'
}

for (x in ds_gfdjacome) {
  dataset_key[x] <-'GFD/Jacome (1978)'
}

for (x in ds_mme) {
  dataset_key[x] <-'MME'
}

for (x in ds_jacome) {
  dataset_key[x] <-'Jacome (1978)'
}

for (x in ds_usgs) {
  dataset_key[x] <-'USGS'
}

for (x in ds_igneominas) {
  dataset_key[x] <-'Igneominas'
}

for (x in ds_agministry) {
  dataset_key[x] <-'Agriculture Ministry'
}

for (x in ds_dane) {
  dataset_key[x] <-'DANE'
}

for (x in ds_dne) {
  dataset_key[x] <-'DNE'
}

for (x in ds_unodc) {
  dataset_key[x] <-'UNODC'
}

for (x in ds_dneunodc) {
  dataset_key[x] <-'DNE/UNODC'
}

for (x in ds_udel) {
  dataset_key[x] <-'UDel'
}

for (x in ds_acemoglu) {
  dataset_key[x] <-'Acemoglu et al. 2015'
}

for (x in ds_authors) {
  dataset_key[x] <-"Authors' Calculations"
}

for (x in ds_usaid) {
  dataset_key[x] <-'USAID'
}

for (x in ds_dubenaidu) {
  dataset_key[x] <-'Dube and Naidu 2015'
}

for (x in ds_dubeusaid) {
  dataset_key[x] <-'USAID/Dube and Naidu 2015'
}

for (c in names(summary_categories)) {
  make_summary_table_colo(filename = paste0('tables/',
                                            country,
                                            '_',
                                            c,
                                            '_summary.tex'),
                          ds=dta, 
                          xlist = summary_categories[[c]], 
                          label.list=ds.labels, 
                          dataset_key=dataset_key, 
                          group="origmun", 
                          outcome=dv)
  
}





